package com.shf.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.shf.entity.Permission;
import com.shf.mapper.PermissionMapper;
import com.shf.service.PermissionService;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 资源权限接口实现类
 * @author 叶枫
 */
@Service("permissionService")
public class PermissionServiceImpl  implements PermissionService {
    @Autowired
    private PermissionMapper permissionMapper;
    @Override
    public PageInfo<Permission> findAll(int page, int size) {

        PageHelper.startPage(page,size);
        List<Permission> allPermission = permissionMapper.findAllPermission();
        PageInfo<Permission> pageInfo = new PageInfo<Permission>(allPermission);

        return pageInfo;

    }

    @Override
    public void save(Permission permission) {

        permissionMapper.addPermission(permission);

    }

    @Override
    public void deleteById(String id) {
        permissionMapper.deletePermissionById(id);

    }


    @Override
    public void deleteMany(String[] ids) {
        permissionMapper.deletManyPermission(ids);


    }
}
